<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>壹装修办公平台</title>
    <link rel="stylesheet" href="/page/layui/css/layui.css">
</head>
<body class="layui-layout-body">
<div class="layui-layout layui-layout-admin">
    <div class="layui-header">
        <div class="layui-logo">壹装修办公平台</div>
        <!-- 头部区域（可配合layui已有的水平导航） -->
        <ul class="layui-nav layui-layout-left">
            <li class="layui-nav-item"><a href="">控制台</a></li>
            <li class="layui-nav-item"><a href="">商品管理</a></li>
            <li class="layui-nav-item"><a href="">用户</a></li>
            <li class="layui-nav-item">
                <a href="javascript:;">其它系统</a>
                <dl class="layui-nav-child">
                    <dd><a href="">邮件管理</a></dd>
                    <dd><a href="">消息管理</a></dd>
                    <dd><a href="">授权管理</a></dd>
                </dl>
            </li>
        </ul>
        <ul class="layui-nav layui-layout-right">
            <li class="layui-nav-item">
                <a href="javascript:;">
                    <img src="http://t.cn/RCzsdCq" class="layui-nav-img">
                    贤心
                </a>
                <dl class="layui-nav-child">
                    <dd><a href="">基本资料</a></dd>
                    <dd><a href="">安全设置</a></dd>
                </dl>
            </li>
            <li class="layui-nav-item"><a href="">退了</a></li>
        </ul>
    </div>

    <div class="layui-side layui-bg-black">
        <div class="layui-side-scroll">
            <!-- 左侧导航区域（可配合layui已有的垂直导航） -->
            <ul class="layui-nav layui-nav-tree" lay-filter="test">
                <li class="layui-nav-item">
                    <a class="" href="javascript:;">我的申请</a>
                    <dl class="layui-nav-child">
                        <dd><a href="/apply/addapply.html" target="main">提交申请</a></dd>
                        <dd><a href="/apply/approve.html" target="main">查看我的审批</a></dd>
                    </dl>
                </li>
                <li class="layui-nav-item">
                    <a href="javascript:;">部门管理</a>
                    <dl class="layui-nav-child">
                        <dd><a href="/menu/addDept.html" target="main">添加部门</a></dd>
                        <dd><a href="/menu/addMenu.html" target="main">修改部门权限</a></dd>
                    </dl>
                </li>
                <li class="layui-nav-item">
                    <a href="javascript:;">角色管理</a>
                    <dl class="layui-nav-child">
                        <dd><a href="/menu/addRole.html" target="main">增加角色</a></dd>
                        <dd><a href="/menu/addRoleMenu.html" target="main">修改角色权限</a></dd>
                    </dl>
                </li>
                <li class="layui-nav-item">
                    <a href="javascript:;">员工管理</a>
                    <dl class="layui-nav-child">
                        <dd><a href="/admin/addEmp.html" target="main">增加员工</a></dd>
                    </dl>
                </li>
                <li class="layui-nav-item">
                    <a href="javascript:;">考勤管理</a>
                    <dl class="layui-nav-child">
                        <dd><a href="/attendance/page/addattendance.html" target="main">增加考勤群组</a></dd>
                        <dd><a href="/attendance/page/attendinfo.html"  target="main">查看考勤群组</a></dd>
                        <dd><a href="/attendance/page/lateattend.html"  target="main">考勤信息统计</a></dd>
                    </dl>
                </li>
                <li class="layui-nav-item">
                    <a href="javascript:;">客户管理</a>
                    <dl class="layui-nav-child">
                        <dd><a href="client/addclient.html" target="main">录入客户信息</a></dd>
                        <dd><a href="client/listclient.html" target="main">查看客户信息</a></dd>
                </li>
                <li class="layui-nav-item">
                    <a href="javascript:;">项目管理</a>
                    <dl class="layui-nav-child">
                        <dd><a href="project/projectlist.html" target="main">查看项目</a></dd>
                        <dd><a href="project/addproject.html" target="main">新增项目</a></dd>

                    </dl>
                </li>
                <li class="layui-nav-item">
                    <a href="javascript:;">材料管理</a>
                    <dl class="layui-nav-child">
                        <dd><a href="/onedecmaterials/addmaterials.html" target="main">材料录入</a></dd>
                        <dd><a href="/onedecmaterials/materials.html" target="main">查看材料</a></dd>

                    </dl>
                </li>
                <li class="layui-nav-item">
                    <a href="javascript:;">财务管理</a>
                    <dl class="layui-nav-child">
                        <dd><a href="/account/account.html" target="main">历史账单</a></dd>
                        <dd><a href="/account/addaccount.html" target="main">添加账单</a></dd>
                        <dd><a href="/finance/numUp.html" target="main">财务报表</a></dd>

                    </dl>
                </li>
                <li class="layui-nav-item"><a href="schedule/myschedule.html" target="main">我的日历</a></li>
                <li class="layui-nav-item"><a href="/camera/checkProject.html" target="main">施工监控</a></li>
            </ul>
        </div>
    </div>

    <div class="layui-body">
        <!-- 内容主体区域 -->
        <div style="padding: 0px;">
            <iframe name="main" class="iframe" width="100%" height="651px" style="border: none"></iframe>
            </iframe></div>
    </div>

    <div class="layui-footer">
        <!-- 底部固定区域 -->
        © layui.com - 底部固定区域
    </div>
</div>
<script src="/page/layui/layui.all.js"></script>
<script src="/page/js/jquery-2.1.4.js"></script>
<script>
    var id;
    $.ajax({
        url: "/admin/current"
        , dataType: "json",
        type: "get",
        success: function (result) {
            id = result.data.empId;
        }
    })
    //JavaScript代码区域
    layui.use('element', function () {
        var element = layui.element;
    });
</script>
<link href="/page/layim/css/layui.css" rel="stylesheet" media="all">
<script src="/page/layim/layui.js" type="text/javascript"></script>
<script>
    layui.use('layim', function (layim) {
        let socket = new WebSocket("ws://192.168.10.62:9007/chat" + "/" + id)
        socket.onopen = () => {
            console.log("连接打开")
        }
        socket.onmessage = ev => {
            var parse = JSON.parse(ev.data);
            layim.getMessage(parse)
        }
        socket.onclose = () => {
            console.log("连接关闭")
        }
        //基础配置
        layim.config({

            init: {
                url: "/page/message/init",
                type: "get",
                data: {}
            } //获取主面板列表信息，下文会做进一步介绍

            //获取群员接口（返回的数据格式见下文）
            , members: {
                url: '' //接口地址（返回的数据格式见下文）
                , type: 'get' //默认get，一般可不填
                , data: {} //额外参数
            }

            //上传图片接口（返回的数据格式见下文），若不开启图片上传，剔除该项即可
            , uploadImage: {
                url: '' //接口地址
                , type: 'post' //默认post
            }

            //上传文件接口（返回的数据格式见下文），若不开启文件上传，剔除该项即可
            , uploadFile: {
                url: '' //接口地址
                , type: 'post' //默认post
            }
            , members: {
                url: "/message/message/groupEmps",
                data: {},
            }
            //扩展工具栏，下文会做进一步介绍（如果无需扩展，剔除该项即可）
            , chatLog: layui.cache.dir + 'css/modules/layim/html/chatLog.html' //聊天记录页面地址，若不开启，剔除该项即可
            , tool: [{
                alias: 'addfriend' //工具别名
                , title: '添加好友' //工具名称
                , icon: '&#xe608;' //工具图标，参考图标文档
            }]

        });
        layim.on('sendMessage', function (result) {
            let mine = result.mine;
            let to = result.to;
            console.log(result)
            socket.send(JSON.stringify({
                type: "chatMessage",
                data: result,
            }))
        })
        layim.on('tool(addfriend)', function (insert, send, obj) { //事件中的tool为固定字符，而code则为过滤器，对应的是工具别名（alias）
            var data1 = obj.data;

            layim.setFriendGroup({
                type: 'friend'
                , username: data1.name //好友昵称，若申请加群，参数为：groupname
                , avatar: data1.avatar //头像
                , group: layim.cache().friend //获取好友列表数据
                , submit: function (group, index) {
                    console.log(group, index)
                    $.ajax({
                        url: "/message/message/addfriend",
                        data: {id: data1.id, group: group},
                        type: "post",
                        dataType: "json",
                        success: function (res) {
                            if (res.code == 200) {
                                window.location.reload()
                            }
                        }
                    })
                }
            });
        });
    });
</script>
</body>
</html>